<?php
session_start();

if(!isset($_SESSION['last_key'])) {
  echo '{"error_code":0, "error":"Not logged in"}';
  return;
}

include_once('config.php');
include_once('weibooauth.php');

$c = new WeiboClient( WB_AKEY , WB_SKEY , $_SESSION['last_key']['oauth_token'] , $_SESSION['last_key']['oauth_token_secret']  );
$me = $c->verify_credentials();

if (!isset($me['error_code']) && !isset($me['error'])) {
  $_SESSION['id'] = $me['id'];
  $_SESSION['name'] = $me['name'];
}

echo json_encode($me);
?>